<template>
<div :class="[$style.container]" @keyup.enter="onConfirm">
<el-dialog title="查看权限" :visible.sync="actualVisible" width="580px">
  <el-table :data="dataSource" style="width: 100%" height="420">
    <el-table-column prop="ownName" label="团队/用户" width="180"></el-table-column>
    <el-table-column prop="docName" label="文档" width="180">
      <template slot-scope="{row}">
        <el-tooltip :content="row.docPath">
          <span>{{row.docName}}</span>
        </el-tooltip>
      </template>
    </el-table-column>
    <el-table-column prop="umask" label="权限" width="180">
      <template slot-scope="{row}">
        <el-tooltip :content="umaskText(row.umask)">
          <span>{{row.umask | perms}}</span>
        </el-tooltip>
      </template>
    </el-table-column>
  </el-table>
</el-dialog>
</div>
</template>

<script lang="ts">

import { Vue, Component, Prop, Emit, Ref } from 'vue-property-decorator'
import { ModalMixins } from '@/mixins'
import { mixins } from 'vue-class-component'
import { textValidator } from '@/config/validator'
import { copyToClipboard } from '@/utils/copy'
import { randomString } from '@/utils/random'
import { createDocLink, updateDocLink } from '@/api/doc-link'
import { getDocPermission } from '@/api/doc'
import { getUmaskText } from '@/config/acl'

@Component
export default class DocPermViewModal extends mixins(ModalMixins) {
  @Ref() fm!: any

  data: any = null

  dataSource: any[] = []

  umaskText (row: any) {
    return getUmaskText(row)
  }

  open (data?: any, row?: any) {
    this.data = data || null
    // this.row = row || null
    getDocPermission(this.data?.parentId).then(data => {
      this.dataSource = data?.aclDTOS || []
    })
    return this.init()
  }

  onCancel () {
    this.cancel()
  }
}
</script>

<style lang="scss" module>
@import "~@/styles/vars.scss";

.container {

}
</style>
